import { cardCache, toast } from 'nc-lightapp-front';
import config from '../config';
import { get } from 'lodash-es';

const { setDefData } = cardCache;

export default function (field, val) {
    const props = this.props;
    if (field === 'jkbxr') {
        const deptid = props.search.getSearchValByField(config.headcode, 'deptid');
        if (get(deptid, 'value.firstvalue') && get(val, 'values.pk_dept.value') !== get(deptid, 'value.firstvalue')) {
            props.search.setSearchValByField(config.headcode, 'deptid', {
                value: get(val, 'values.pk_dept.value'),
                display: get(val, 'values.deptname.value')
            });
        }
    } else if (field === 'deptid') {
        props.search.setSearchValByField(config.headcode, 'jkbxr', {
            value: null,
            display: null
        });
    }
}
